package org.jeecg.modules.flow.activiti.config;

import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.jeecg.modules.flow.activiti.listener.GlobalEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * activiti配置类
 */
@Component
public class ActivitiConfig implements ProcessEngineConfigurationConfigurer, Serializable {

    @Autowired
    private GlobalEventListener globalEventListener;

    @Override
    public void configure(SpringProcessEngineConfiguration springProcessEngineConfiguration) {

        List<ActivitiEventListener> eventListeners = new ArrayList<>();
        eventListeners.add(globalEventListener);
        // 添加监听器
        springProcessEngineConfiguration.setEventListeners(eventListeners);

    }
}
